package com.smartcruise.data.cruiseData;

import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.LatLngBounds;

import io.realm.RealmList;
import io.realm.RealmObject;

//巡护地图
public class PatrollingMapEntityBean extends RealmObject {
    /**
     * coordinate : [{"lng":118.48787605762482,"lat":32.07421785886467},{"lng":118.48664224147797,"lat":32.073426921323616},{"lng":118.4869533777237,"lat":32.072258684968034},{"lng":118.48909914493561,"lat":32.07222459224323},{"lng":118.49079966545105,"lat":32.07400194268616}]
     * coordinateList : [{"lat":"32.07421785886467","lng":"118.48787605762482"},{"lat":"32.073426921323616","lng":"118.48664224147797"},{"lat":"32.072258684968034","lng":"118.4869533777237"},{"lat":"32.07222459224323","lng":"118.48909914493561"},{"lat":"32.07400194268616","lng":"118.49079966545105"}]
     * id : 5a6ecbe760a8cd05a4c0fb7a
     * name : 地图1
     * subjectId : 5a3212d2bd527c153821a246
     */

    private String coordinate;
    private String id;
    private String name;
    private String subjectId;
    private RealmList<CoordinateBean> coordinateList;

    public String getCoordinate() {
        return coordinate;
    }

    public void setCoordinate(String coordinate) {
        this.coordinate = coordinate;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSubjectId() {
        return subjectId;
    }

    public void setSubjectId(String subjectId) {
        this.subjectId = subjectId;
    }

    public RealmList<CoordinateBean> getCoordinateList() {
        return coordinateList;
    }

    public void setCoordinateList(RealmList<CoordinateBean> coordinateList) {
        this.coordinateList = coordinateList;
    }

    //获取一个矩形边界
    public LatLngBounds getLatBounds() {
        if (coordinateList != null && !coordinateList.isEmpty()) {
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            for (CoordinateBean coordinateBean : coordinateList) {
                builder.include(new LatLng(coordinateBean.getLatDouble(), coordinateBean.getLngDouble()));
            }
            return builder.build();
        } else {
            return null;
        }
    }

}